package io.renren.modules.app.dao;

import io.renren.modules.app.entity.ImMomentCommentEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 *
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-05-25 08:44:56
 */
@Mapper
public interface ImMomentCommentDao extends BaseMapper<ImMomentCommentEntity> {

    @Select("SELECT mc.content,\n" +
            "\tu.user_id uid,\n" +
            "\n" +
            "IF (\n" +
            "\tu.nickname = NULL,\n" +
            "\tu.username,\n" +
            "\tu.nickname\n" +
            ") uname,\n" +
            "ue.user_id rid,\n" +
            "IF (\n" +
            "\tue.nickname = NULL,\n" +
            "\tue.username,\n" +
            "\tue.nickname\n" +
            ") rname\n" +
            "FROM\n" +
            "\tim_moment_comment mc LEFT JOIN tb_user ue ON ue.user_id = mc.reply_id,\n" +
            "\ttb_user u  \n" +
            "WHERE\n" +
            "\t\n" +
            "\tu.user_id = mc.user_id\n" +
            "AND mc.moment_id = #{id}")
    List<ImMomentCommentEntity> selectUrList(Integer id);
}
